<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;

class CreateO2oRefundTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $prefix = config('ibrand.app.database.prefix', 'ibrand_');
        if (!Schema::hasTable($prefix . 'o2o_refund')) {
            Schema::create($prefix . 'o2o_refund', function (Blueprint $table) {
                $table->increments('id');
                $table->string('refund_no'); //退款编号
                $table->integer('user_id')->unsigned(); //申请人
                $table->integer('clerk_id')->unsigned()->nullable(); // 处理人
                $table->integer('order_id'); //订单ID
                $table->integer('shop_id')->default(0);
                $table->integer('type'); //1：退货， 2：换货
                $table->integer('quantity'); //数量
                $table->integer('amount'); //退款金额
                $table->integer('actual_amount')->default(0); //实退金额
                $table->text('content')->nullable();//问题描述
                $table->integer('status')->default(0);//0:临时单据 1:已完成
                $table->text('images')->nullable();
                $table->timestamps();
            });
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        $prefix = config('ibrand.app.database.prefix', 'ibrand_');
        
        Schema::drop($prefix . 'o2o_refund');
    }
}
